﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Warensoft.Unity.Communication.Client.OData;

namespace Warensoft.Unity.Communication.Client.Models
{
    public class ODataEntityCollection:ICollection<ODataEntity>
    {
        private List<ODataEntity> entities = new List<ODataEntity>();
        public void Add(ODataEntity item)
        {
            this.entities.Add(item);
        }

        public void Clear()
        {
            this.entities.Clear();
        }

        public bool Contains(ODataEntity item)
        {
            return this.entities.Contains(item);
        }

        public void CopyTo(ODataEntity[] array, int arrayIndex)
        {
            foreach (var item in this.entities)
            {
                array.SetValue(item,arrayIndex);
                arrayIndex++;
            }
        }

        public int Count
        {
            get { return this.entities.Count; }
        }

        public bool IsReadOnly
        {
            get { return false; }
        }

        public bool Remove(ODataEntity item)
        {
            return this.entities.Remove(item);
        }

        public IEnumerator<ODataEntity> GetEnumerator()
        {
            return this.entities.GetEnumerator();
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return this.entities.GetEnumerator();
        }
    }
}
